package com.xxx.system.controller;


import com.github.pagehelper.PageInfo;
import com.xxx.base.utils.R;
import com.xxx.system.domain.Employee;
import com.xxx.system.query.EmployeeQuery;
import com.xxx.system.service.IEmployeeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

@RestController //默认返回json格式，前后端分离
@RequestMapping("/employee")
@Api(tags = "员工接口类")
public class EmployeeController {
@Autowired
private IEmployeeService employeeService;

    @ApiOperation("分页查询")
    @PostMapping
    public PageInfo<Employee> queryByPage(@RequestBody EmployeeQuery employeeQuery){
        ArrayList<Employee> list=employeeService.queryByPage(employeeQuery);
        return new PageInfo<Employee>(list);
    }

    @ApiOperation("新增或者编辑")
    @PutMapping
    public R<Void> updateOrInsert(@RequestBody Employee employee){
        employeeService.updateOrInsert(employee);
        return R.ok();
    }

    @ApiOperation("删除单个")
    @DeleteMapping
    public R<Void> deleteSin(@RequestBody Employee employee){
        employeeService.deleteSin(employee);
        return R.ok();
    }

    @ApiOperation("删除多个")
    @PatchMapping("/deleteMul")
    public R<Void> deleteMul(@RequestBody Long[] arr){
        employeeService.deleteMul(arr);
        return R.ok();
    }
}